﻿@{
    ViewBag.Title = "MusicFile";
}

<div id="LuceneDotNet_MusicFile_toolbarExt">
    <a href="javascript:void(0)" class="easyui-linkbutton"
       onclick="LuceneDotNet.MusicFile.AddIndex()"
       data-options="plain: true, iconCls: 'icon-add'">添加索引</a>
    <a href="javascript:void(0)" class="easyui-linkbutton" 
       onclick="LuceneDotNet.MusicFile.DelIndex()"
       data-options="plain: true, iconCls: 'icon-remove'">清空索引</a>
</div>

@RenderPage("~/Views/Shared/DataGrid.cshtml")

<script type="text/javascript">
    LuceneDotNet.MusicFile.AddIndex = function () {
        $.messager.prompt('Create Index', 'Please enter a folder path:', function (path) {
            if (path) {
                var watch = new Stopwatch();
                watch.Start();
                $.ajax({
                    url: '/Laboratory/LuceneDotNet/MusicFile/',
                    type: 'POST',
                    async: true,
                    data: {
                        path: path
                    }
                }).then(function (data) {
                    watch.Stop();
                    console.log(watch.GetTime());
                    LuceneDotNet.MusicFile.Search();
                });
            }
        });
    };
    LuceneDotNet.MusicFile.DelIndex = function () {
        var watch = new Stopwatch();
        watch.Start();
        $.ajax({
            url: '/Laboratory/LuceneDotNet/MusicFile/',
            type: 'DELETE',
            async: true
        }).then(function (data) {
            watch.Stop();
            console.log(watch.GetTime());
            LuceneDotNet.MusicFile.Search();
        });
    };
    LuceneDotNet.MusicFile.Search = function (value, name) {
        LuceneDotNet.MusicFile.$grid.datagrid('load', {
            q: value,
            filed: name
        });
    };
</script>